package com.yangt.service.impl;

import com.google.common.collect.Maps;
import com.yangt.service.MainService;
import com.yangt.service.SecondService;
import com.yangt.service.ThirdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author hongbin.yang
 * @date 2016-06-03 10:43
 */
public class MainServiceImpl implements MainService {

    private SecondService secondService;

    private ThirdService thirdService;

    /**
     * 调用SecondService就好
     *
     * @param name
     * @return
     */
    @Override
    public String sayHello(String name) {
        secondService.getUserMsg(name);
        return "hello " + name;
    }

    /**
     * 调用second、third
     *
     * @param name
     * @return
     */
    @Override
    public Map<String, Object> getUserInfo(String name) {
        Map<String, Object> temp = Maps.newHashMap();
        temp.put("user", secondService.getUserMsg(name));
        temp.put("shop", thirdService.getShopInfo(name));
        return temp;
    }

    public void setSecondService(SecondService secondService) {
        this.secondService = secondService;
    }

    public void setThirdService(ThirdService thirdService) {
        this.thirdService = thirdService;
    }
}
